(function(){
    function init() {
        map = new AMap.Map("mapContainer", {
            zoom: 11,
            center:[116.473188,39.993253],
            resizeEnable: true
        });
        AMap.plugin('AMap.PlaceSearch',function(){
            var placeSearch = new AMap.PlaceSearch({
                city:'010',
                pageSize:1
            })
            

            placeSearch.search('津滨腾跃大厦',function(status,data){
                if(status!=='complete')return;
                var pois = data.poiList.pois;
                for(var i=1;i<pois.length+1;i+=1){
                    var marker = new AMap.Marker({
                        content:'<div class="marker" >'+i+'</div>',
                        position:pois[i-1].location,
                        map:map,
                    })
                    marker.setLabel({
                        offset: new AMap.Pixel(20, 20),//修改label相对于maker的位置
                        content: pois[i-1].name
                    });
                    marker.id= pois[i-1].id;
                    marker.name = pois[i-1].name;
                    marker.on('click',function(){
                        map.poiOnAMAP({
                            name:this.name,
                            location:this.getPosition(),
                            id:this.id
                        })
                    })
                }
                map.setFitView();
                map.setZoom(15);
            })
            placeSearch.search('珠江新城雅居乐中心',function(status,data){
                if(status!=='complete')return;
                var pois = data.poiList.pois;
                for(var i=1;i<pois.length+1;i+=1){
                    var marker = new AMap.Marker({
                        content:'<div class="marker" >'+(i+1)+'</div>',
                        position:pois[i-1].location,
                        map:map,
                    })
                    marker.setLabel({
                        offset: new AMap.Pixel(20, 20),//修改label相对于maker的位置
                        content: pois[i-1].name
                    });
                    marker.id= pois[i-1].id;
                    marker.name = pois[i-1].name;
                    marker.on('click',function(){
                        map.poiOnAMAP({
                            name:this.name,
                            location:this.getPosition(),
                            id:this.id
                        })
                    })
                }
                map.setFitView();
                map.setZoom(15);
            })
        })
        map.addControl(new AMap.ToolBar());
        if(AMap.UA.mobile){
            document.getElementById('button_group').style.display='none';
        }
    }
    window.document.onload = init();
})();